home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / WEATHER.C < prev   
Encoding:
C/C++ Source or Header  |  1988-03-30  |  506 b   |  24 lines

  1. /* weather.c - calculate average temp. and # cold days*/
  2. #include "stdio.h"
  3.  
  4. #define FREEZE    32    /* freezing temperature */
  5.  
  6. main()
  7.   {
  8.     int i , temp , ncold ;
  9.     float sum ;
  10.  
  11.     printf(" Enter temperatures for the week \n") ;
  12.     ncold = 0 ;
  13.     sum = 0 ;
  14.     for(i=0 ; i < 7 ; i=i+1 )
  15.       { scanf("%d",&temp) ;
  16.         sum = sum + temp ;
  17.         if( temp < FREEZE )
  18.         ncold = ncold + 1 ;
  19.       }
  20.     printf(" Average temperarure was %3.1f \n",sum / 7.0 );
  21.     printf(" %d  days below freezeng \n",ncold) ;
  22.   }
  23.  
  24.